<template>
  <Echart :options="options" id="centreLeft1Chart" height="500px" width="600px"></Echart>
</template>

<script>
import Echart from "@/common/echart";

const animationDuration = 6000;

export default {
  props: {
    cdata: {
      type: Object,
      default: () => ({})
    }
  },
  components: {
    Echart
  },
  data() {
    return {
       options: {},
    };
  },
  watch: {
    cdata: {
      handler(newData) {
        this.options = {
          tooltip: {
            trigger: "axis",
            axisPointer: {
              // 坐标轴指示器，坐标轴触发有效
              type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
            },
            textStyle:{ 
              fontSize:22
            }
          },
          grid: {
            top: 10,
            left: "2%",
            right: "2%",
            bottom: "3%",
            containLabel: true
          },
          xAxis: [
            {
              type: "category",
              data: newData.xData,
              axisTick: {
                alignWithLabel: true
              },
              axisLabel:{ 
                fontSize:22
              }
            }
          ],
          yAxis: [
            {
              type: "value",
              axisTick: {
                show: false
              },
              axisLabel:{ 
                fontSize:22
              }
            }
          ],
          series: [
            {
              name: newData.seriesName,
              type: "bar",
              stack: "vistors",
              barWidth: "60%",
              data: newData.seriesData,
              animationDuration
            }
          ]
        };
      },
      immediate: true,
      deep: true
    }
  }
};
</script>
